<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      >
      <f:metadata>
    	   <f:viewParam name="subject" value="#{subjectsBean.subjectId}"/>
	    </f:metadata>
      <head><title>IGNORED</title></head>
       <body>
      <ui:composition template="/templates/masterLayout.xhtml">
         <ui:define name="windowTitle">
            Предметы
         </ui:define>
         <ui:define name="content">
         <h:panelGroup rendered="#{authBean.loggedIn and authBean.currentUser.isAdministrator}">
         <h2>Добавить новый предмет</h2>
<h:form>
<div>
    <h:outputLabel for="subjectName" value="Название предмета:" />
    <h:inputText id="subjectName" value="#{subjectsBean.subject.name}" required="true" />
</div>
<div>
    <h:commandButton value="Добавить предмет" action="#{subjectsBean.createSubject}" />
</div>
<div>
    <h:messages />
</div>
</h:form>
</h:panelGroup>
<div>
    <h:dataTable value="#{subjectsBean.subjects}" var="subject">
    <h:column>
        <f:facet name="header">
            <h:outputText value="Название предмета" />
        </f:facet>
        <h:link outcome="publicMessages.xhtml" includeViewParams="true" value="#{subject.name}">
   			<f:param name="group" value="#{sibject.id}"/> 
		</h:link>
    </h:column>
     <h:column rendered="#{authBean.loggedIn and authBean.currentUser.isAdministrator}">
        <f:facet name="header">
            <h:outputText value="" />
        </f:facet>
        <h:form>
        	<h:commandButton value="Удалить" action="#{subjectsBean.deleteSubject}">
        		<f:param name="subject" value="#{subject.id}"/>
        	</h:commandButton>
        </h:form> 
    </h:column>
</h:dataTable>
</div>
         </ui:define>
      </ui:composition>
   </body>
 </html>
